<template>
  <div>
    <div>
      需求状态
      <div id="main" style="width: 600px; height: 400px"></div>
    </div>
    <div>
      
      <div id="main1" style="width: 600px; height: 400px"></div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  data() {
    return {
      status: "",
      count: "",
      lst: [],
    };
  },
  mounted() {
    this.gettj();
    this.getwc();
  },
  methods: {
    gettj() {
      this.axios.get("/tong").then((res) => {
        this.count = res.data.count;
        this.status = res.data.status;
        this.opens();
      });
    },
    getwc() {
      this.axios.get("/wc").then((res) => {
        this.lst = res.data.data;
        this.openq();
      });
    },
    opens() {
      var chartDom = document.getElementById("main");
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        xAxis: {
          type: "category",
          data: this.status,
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: this.count,
            type: "bar",
            showBackground: true,
            backgroundStyle: {
              color: "rgba(180, 180, 180, 0.2)",
            },
          },
        ],
      };

      option && myChart.setOption(option);
    },
    openq() {
      var chartDom = document.getElementById("main1");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        title: {
          text: "需求完成率",
          subtext: "Fake Data",
          left: "center",
        },
        tooltip: {
          trigger: "item",
        },
        legend: {
          orient: "vertical",
          left: "left",
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: "50%",
            data: this.lst,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(0, 0, 0, 0.5)",
              },
            },
          },
        ],
      };
      option && myChart.setOption(option);
    },
  },
};
</script>

<style>
</style>